package com.ysstech.reportworld.enums;

import com.ysstech.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 系统常量
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum ReportWorldStatusEnum implements BaseEnum<Integer> {
    REPORT_NORMAL(1, "已确认"),
    REPORT_DELETED(2, "已删除"),
    REPORT_WAITING_REVIEW(3, "待审核"),
    REPORT_UNDER_REVIEW(4, "审核中"),
    REPORT_FAIL_REVIEW(5, "审核不通过");

    private final Integer code;
    private final String desc;

    public static ReportWorldStatusEnum getEnum(Integer code) {
        return Arrays.stream(values()).filter(b -> Objects.equals(b.code, code)).findFirst().orElse(null);
    }

    public static String getEnumDesc(Integer code) {
        ReportWorldStatusEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }

    /**
     * 升级工具需要的数据状态类型 只有1 正常 和2 已删除
     *
     * @return
     */
    public static List<Integer> getUpgradeToolsZipStatus() {
        List<Integer> list = new ArrayList<>();
        for (ReportWorldStatusEnum statusEnum : ReportWorldStatusEnum.values()) {
            if (null == statusEnum) {
                continue;
            }
            if (1 == statusEnum.getCode() || 2 == statusEnum.getCode()) {
                list.add(statusEnum.getCode());
            }
        }
        return list;

    }
}
